package com.zhx.real.security.handler;

import cn.hutool.json.JSONUtil;
import org.springframework.security.core.Authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author zhanghaixuan
 * @create 2018/4/18-上午11:09
 **/
public interface CuestomAuthentionSuccessHandler {
	/**
	 * 用户登录成功后的自定义消息接口
	 * @param request 请求
	 * @param httpServletResponse response
	 * @param authentication 登录后的信息
	 * @throws IOException io异常
	 */
	default void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse,
                                         Authentication authentication) throws IOException {
		httpServletResponse.setContentType("application/json,charset=UTF-8");
		httpServletResponse.getWriter().write(JSONUtil.toJsonStr(authentication));
	}
}
